package com.example.site.util;

import org.springframework.util.DigestUtils;

import java.security.SecureRandom;
import java.util.Base64;

public class PasswordUtil {

    private static final SecureRandom secureRandom = new SecureRandom();

    public static String readSalt() {
        MyAppProperties myAppProperties = new MyAppProperties();
        return myAppProperties.getSalt();
    }

    public static String encryptPassword(String password) {
        String saltedPassword = PasswordUtil.readSalt() + password;
        return DigestUtils.md5DigestAsHex(saltedPassword.getBytes());
    }
}

